<?php
include("_mysql.php");
include("_settings.php");
include("_functions.php");

$id = $_POST['item'];
$bets = safe_query("SELECT b.betID, u.username, b.money, b.date, b.itemID FROM bets AS b INNER JOIN user AS u ON b.user = u.userID where b.itemID = '".$id."' ORDER BY b.date DESC LIMIT 0, 5");

$json_result = array();
$count = 1;
while($bet = mysql_fetch_array( $bets ))
{            	
	$class = (time() - $bet["date"]) <= 60*10 ? "icon-green" : "icon-yellow";
	$when = (time() - $bet["date"]) <= 60*10 ? "just" : "has";
	$json_result[$bet["betID"]] = <<<EOD
				<li>
					<span class="id" style="display: none">{$bet["betID"]}</span>
                	<span class="{$class}"><strong>{$bet["username"]}</strong> {$when} placed a bet</span>                    
                    <span class="bets-price">\${$bet["money"]}</span>
                </li>
EOD;
	$count ++;
}

echo json_encode($json_result);
?>